package cn.tomas.queue.delayQueue.sender;

import cn.tomas.queue.delayQueue.config.DelayQueueConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DelayMessageSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMsg(String msg, int type){
        switch (type){
            case 10:
                rabbitTemplate.convertAndSend(DelayQueueConfig.DELAY_EXCHANGE_NAME, DelayQueueConfig.DELAY_QUEUE_A_ROUTING_KEY, msg);
                break;
            case 60:
                rabbitTemplate.convertAndSend(DelayQueueConfig.DELAY_EXCHANGE_NAME, DelayQueueConfig.DELAY_QUEUE_B_ROUTING_KEY, msg);
                break;
            default: break;
        }
    }
}